﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GameEngine.Clients.Silverlight.View.Components
{
    public partial class DesktopUC:UserControl
    {
        public delegate void OnKeyHandler(KeyEventArgs key);
        public event OnKeyHandler OnKeyUpEvent;
        public event OnKeyHandler OnKeyDownEvent;
        UIElement CurrentScreen;

        public DesktopUC()
        {
            InitializeComponent();
            
        }

        public void setScreen(UIElement screen)
        {
            //if (CurrentScreen != null)
            //    LayoutRoot.Children.Remove(CurrentScreen);
            LayoutRoot.Children.Clear();
            CurrentScreen = screen;
            //screen.SetValue(Canvas.ZIndexProperty, 2);
            //((DesktopUC)Application.Current.RootVisual).LayoutRoot.Children.Add(screen);
                LayoutRoot.Children.Add(screen);
            //LayoutRoot.Children.Insert(0, screen);


            ///frame.Navigate(new Uri("/myOtherUserControl.xaml", UriKind.Relative));
            //  ViewComponent.Canvas.Children.Clear();//TODO unregistermediator?
            //ViewComponent.Canvas.Children.Add(component);
        }

        private void UserControl_KeyUp(object sender, KeyEventArgs e)
        {
            if(OnKeyUpEvent!=null)
                OnKeyUpEvent(e);
        }

        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if(OnKeyDownEvent!=null)
                OnKeyDownEvent(e);
        }
    }
}
